package poker;

import exception.InvalidCardEx;

public class Card {
	private short c;

	public Card(short i) throws InvalidCardEx {
		this((int) i);
	}

	public Card(int i) throws InvalidCardEx {
		if (i > 51 || i < 0) {
			throw new InvalidCardEx();
		} else {
			c = (short) i;
		}
	}

	public short getCard() {
		return c;
	}

	public void setCard(int i) throws InvalidCardEx {
		if (i <= 51 && i > -1) {
			c = (short) i;
		} else {
			throw new InvalidCardEx();
		}
	}

	public void setCard(short i) throws InvalidCardEx {
		setCard((int) i);
	}
	
	public String getCardTxt() {
		String s;
		if (c%13 == 0) { s = new String("Dwójka "); }
		else if (c%13 == 1) { s = new String("Trójka "); }
		else if (c%13 == 2) { s = new String("Czwórka "); }
		else if (c%13 == 3) { s = new String("Piątka "); }
		else if (c%13 == 4) { s = new String("Szóstka "); }
		else if (c%13 == 5) { s = new String("Siódemka "); }
		else if (c%13 == 6) { s = new String("Ósemka "); }
		else if (c%13 == 7) { s = new String("Dziewiątka "); }
		else if (c%13 == 8) { s = new String("Dziesiątka "); }
		else if (c%13 == 9) { s = new String("Jopek "); }
		else if (c%13 == 10) { s = new String("Dama "); }
		else if (c%13 == 11) { s = new String("Król "); }
		else if (c%13 == 12) { s = new String("As "); }
		else { return null; }
		
		if (c/13 == 0) { return s + "kier"; }
		else if (c/13 == 1) { return s + "karo"; }
		else if (c/13 == 2) { return s + "trefl"; }
		else if (c/13 == 3) { return s + "pik"; }
		else { return null; }
	}

}
